<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <swiper-slide v-for="item of list" :key="item.movie_id">
        <img class="swiper-img" :src="'http://'+ item.huge_pic" :data-id="item.movie_id" @click="imgClick"/>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        },
        loop: true,
        direction: 'horizontal'
      }
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  },
  methods: {
    imgClick (e) {
      this.$router.push('/detail/' + e.target.dataset.id)
    }
  }
}
</script>
<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
    background: #fff
  .wrapper
    margin-top: .60rem
    overflow: hidden
    width: 100%
    height: 0
    padding-bottom: 33.2%
    background: #eee
    .swiper-img
      width: 100%
</style>
